package com.fc.backingbeans.journal;

import javax.faces.bean.ViewScoped

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

import com.fc.backingbeans.AbstractDialog
import com.fc.entities.Measurement
import com.fc.entities.MeasurementType
import com.fc.service.UserDetailsService;
import com.fc.service.MeasurementService
import com.fc.service.MeasurementTypeService

/**
 * 
 * @author Ács Ádám
 *
 */
@Component("addMeasurementDialog")
@ViewScoped
class AddMeasurementDialog extends AbstractDialog {
	@Autowired private MeasurementService measurementService
	@Autowired private UserDetailsService userDetailsService
	Measurement measurement = new Measurement()

	void save() {
		measurement.user = userDetailsService.currentUser
		measurementService.create(measurement)
		measurement = new Measurement()
	}
	
	@Override
	String getDialogName() {
		"fc/journal/addMeasurementJournalEntry"
	}
	
	Map getOptions() {
		[
			modal: true
			,draggable: false
			,resizable: false
			,contentWidth: 550
			,width:600
			,contentHeight: 550
			,height: 600
		]
	}
}
